package network;

import java.io.IOException;
import java.net.SocketException;
import java.util.HashMap;
import java.util.Map;

//字典服务器
public class UdpDictServer extends UdpEchoServer {
    private Map<String,String> dict = new HashMap<>();
    public UdpDictServer(int port) throws SocketException {
        super(port);

        dict.put("tie","关系,领带,平局");
        dict.put("socket","插口,插座");
        dict.put("buffer","缓冲区");
        dict.put("lenovo","联想");
        dict.put("dog","狗");
        dict.put("cat","猫");
    }

    @Override
    public String process(String request) {
        return dict.getOrDefault(request,"未知单词");
    }

    public static void main(String[] args) throws IOException {
        UdpDictServer sever = new UdpDictServer(9090);
        sever.start();
    }

}
